package com.paas.form.core.element.control.impl.searchItem;

import com.paas.common.util.StringUtil;
import com.paas.form.core.element.control.FormItem;
import com.paas.form.core.element.field.FieLdsModel;
import com.paas.form.core.element.jsContent.ScriptContent;
import lombok.Data;


@Data
public class UserSelectMul implements FormItem {
    private FieLdsModel field;
    private String htmlType;
    public static final String USER_SELECT_MUL ="<user-select v-model=\"${formObject}.${field.vModel}\" placeholder=\"请选择${field.config.label}\" clearable\n" +
            "                class=\"item\"\n" +
            "                selectType=\"${field.selectType}\"\n" +
            "                :ableDepIds=\"${field.ableDepIds}\" :ablePosIds=\"${field.ablePosIds}\"\n" +
            "                :ableUserIds=\"${field.ableUserIds}\" :ableRoleIds=\"${field.ableRoleIds}\"\n" +
            "                :ableGroupIds=\"${field.ableGroupIds}\" :multiple=\"${field.multiple}\" />";

    public UserSelectMul(FieLdsModel field, String htmlType){
        this.field = field;
        this.htmlType = htmlType;

    }

    public String getUserSelectMul(FieLdsModel field){
        String userSeltctMulStr= "<user-select v-model=\"${formObject}.${field.vModel}\" placeholder=\"请选择${field.config.label}\" clearable  class=\"item\"  selectType=\"${field.selectType}\"  " +
                "  :multiple=\"${field.multiple}\"";
        if(StringUtil.isNotEmpty(field.getAbleDepIds())){
            userSeltctMulStr= userSeltctMulStr +"    :ableDepIds=\"" +field.getAbleDepIds().replaceAll("\"","'") +"\"";
        }
        if(StringUtil.isNotEmpty(field.getAblePosIds())){
            userSeltctMulStr= userSeltctMulStr +"    :ablePosIds=\"" +field.getAblePosIds().replaceAll("\"","'") +"\"";
        }
        if(StringUtil.isNotEmpty(field.getAbleUserIds())){
            userSeltctMulStr= userSeltctMulStr +"    :ableUserIds=\"" +field.getAbleUserIds().replaceAll("\"","'") +"\"";
        }
        if(StringUtil.isNotEmpty(field.getAbleRoleIds())){
            userSeltctMulStr= userSeltctMulStr +"    :ableRoleIds=\"" +field.getAbleRoleIds().replaceAll("\"","'") +"\"";
        }
        if(StringUtil.isNotEmpty(field.getAbleGroupIds())){
            userSeltctMulStr= userSeltctMulStr +"    :ableGroupIds=\"" +field.getAbleGroupIds().replaceAll("\"","'") +"\"";
        }
        userSeltctMulStr = userSeltctMulStr +"  />";
        return userSeltctMulStr;
    }


    @Override
    public String makeVue() {
        return getUserSelectMul(this.field);
    }

    @Override
    public ScriptContent makeJs() {
        return null;
    }
}
